package ar.com.ctrln.view.render.compras.insumo;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Label;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import org.zkoss.zul.Vlayout;
import org.zkoss.zul.Window;

import ar.com.ctrln.persistence.model.insumo.Insumo;

public class InsumoItemRender implements ListitemRenderer<Insumo>{

	
	public void render(Listitem item, Insumo data, int arg) throws Exception {
		Vlayout stock = new Vlayout();
		Insumo ins = (Insumo) data;
		Listcell cell1= new Listcell(ins.getTipoInsumo());
		Listcell cell2= new Listcell(ins.getNombre());
		Listcell cell3= new Listcell();
		Label cant = new Label(Integer.toString(ins.getStock()));
		Label uni = new Label (ins.getUnidadMedida());
		uni.setStyle("font-size:10px;");
		cant.setParent(stock);
		uni.setParent(stock);
		stock.setParent(cell3);
		cell1.setParent(item);
		cell2.setParent(item);
		cell3.setParent(item);
		item.addEventListener("onDoubleClick", new EditarInsumoListener());
		item.setTooltiptext(ins.getDescripcion());
    	item.setAttribute("data", data);
    	item.setDraggable("true");	
		} 
}

class EditarInsumoListener implements org.zkoss.zk.ui.event.EventListener {
    
Window wConsultarInsumo;

	@Override
	public void onEvent(Event evt) throws Exception {
	
		Executions.createComponents("/zul/mantenimiento/insumos/editarInsumo.zul",wConsultarInsumo, null);
	

}
}
